package com.tz.farmer;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.client.RestTemplate;


/**
 *  Demo class
 *
 *  @author xhj
 *  @date 2019/05/14
 */
@SpringBootApplication
@EnableCaching(proxyTargetClass = true)
@ComponentScan(basePackages = {"com.tz"})
@MapperScan({"com.tz.farmer.mapper"})
@EnableTransactionManagement  //开启事务支持
@EnableScheduling
public class SpringBootFarmerServerWebApplication extends SpringBootServletInitializer implements WebApplicationInitializer {
    @Override
    public SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(SpringBootFarmerServerWebApplication.class);
    }

    /**
     * 入口
     *
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
        SpringApplication.run(SpringBootFarmerServerWebApplication.class, args);
    }

    @Bean
    RestTemplate restTemplate(){
        return new RestTemplate();
    }

}
